package main

import "honnef.co/go/gotraceui/trace/ptrace"

// Mapping from states to span labels
var spanStateLabels = [...][]string{
	ptrace.StateUndetermined:            {"undetermined"},
	ptrace.StateInactive:                {"inactive"},
	ptrace.StateActive:                  {"active"},
	ptrace.StateGCIdle:                  {"GC (idle)", "I"},
	ptrace.StateGCDedicated:             {"GC (dedicated)", "D"},
	ptrace.StateGCFractional:            {"GC (fractional)", "F"},
	ptrace.StateBlocked:                 {"blocked"},
	ptrace.StateBlockedSend:             {"send"},
	ptrace.StateBlockedRecv:             {"recv"},
	ptrace.StateBlockedSelect:           {"select"},
	ptrace.StateBlockedSync:             {"sync"},
	ptrace.StateBlockedSyncOnce:         {"sync.Once"},
	ptrace.StateBlockedSyncTriggeringGC: {"triggering GC", "T"},
	ptrace.StateBlockedCond:             {"sync.Cond"},
	ptrace.StateBlockedNet:              {"I/O"},
	ptrace.StateBlockedGC:               {"GC assist wait", "W"},
	ptrace.StateBlockedSyscall:          {"syscall"},
	ptrace.StateStuck:                   {"stuck"},
	ptrace.StateReady:                   {"ready"},
	ptrace.StateWaitingPreempted:        {"preempted"},
	ptrace.StateCreated:                 {"created"},
	ptrace.StateGCMarkAssist:            {"GC mark assist", "M"},
	ptrace.StateGCSweep:                 {"GC sweep", "S"},
	ptrace.StateProcRunningNoG:          {"no goroutine"},
	ptrace.StateLast:                    nil,
}

// Mapping from states to tooltips
var tooltipStateLabels = [ptrace.StateLast]string{
	ptrace.StateUndetermined:            "State: undetermined",
	ptrace.StateInactive:                "State: inactive",
	ptrace.StateActive:                  "State: active",
	ptrace.StateGCDedicated:             "State: GC (dedicated)",
	ptrace.StateGCFractional:            "State: GC (fractional)",
	ptrace.StateGCIdle:                  "State: GC (idle)",
	ptrace.StateBlocked:                 "State: blocked",
	ptrace.StateBlockedSend:             "State: blocked on channel send",
	ptrace.StateBlockedRecv:             "State: blocked on channel recv",
	ptrace.StateBlockedSelect:           "State: blocked on select",
	ptrace.StateBlockedSync:             "State: blocked on mutex",
	ptrace.StateBlockedSyncOnce:         "State: blocked on sync.Once",
	ptrace.StateBlockedSyncTriggeringGC: "State: blocked triggering GC",
	ptrace.StateBlockedCond:             "State: blocked on condition variable",
	ptrace.StateBlockedNet:              "State: blocked on polled I/O",
	ptrace.StateBlockedGC:               "State: GC assist wait",
	ptrace.StateBlockedSyscall:          "State: blocked on syscall",
	ptrace.StateStuck:                   "State: stuck",
	ptrace.StateReady:                   "State: ready",
	ptrace.StateWaitingPreempted:        "State: preempted",
	ptrace.StateCreated:                 "State: ready",
	ptrace.StateGCMarkAssist:            "State: GC mark assist",
	ptrace.StateGCSweep:                 "State: GC sweep",

	ptrace.StateProcRunningNoG:     "State: running without goroutine",
	ptrace.StateProcRunningG:       "State: running with goroutine",
	ptrace.StateProcRunningBlocked: "State: running with blocked goroutine",
}

// Mapping from states to their names as used by statistics, filters, etc.
var stateNames = [ptrace.StateLast]string{
	ptrace.StateUndetermined:            "undetermined",
	ptrace.StateInactive:                "inactive",
	ptrace.StateActive:                  "active",
	ptrace.StateGCIdle:                  "GC (idle)",
	ptrace.StateGCDedicated:             "GC (dedicated)",
	ptrace.StateGCFractional:            "GC (fractional)",
	ptrace.StateBlocked:                 "blocked (other)",
	ptrace.StateBlockedSend:             "blocked (channel send)",
	ptrace.StateBlockedRecv:             "blocked (channel receive)",
	ptrace.StateBlockedSelect:           "blocked (select)",
	ptrace.StateBlockedSync:             "blocked (sync)",
	ptrace.StateBlockedSyncOnce:         "blocked (sync.Once)",
	ptrace.StateBlockedSyncTriggeringGC: "blocked (triggering GC)",
	ptrace.StateBlockedCond:             "blocked (sync.Cond)",
	ptrace.StateBlockedNet:              "blocked (pollable I/O)",
	ptrace.StateBlockedGC:               "blocked (GC)",
	ptrace.StateBlockedSyscall:          "blocked (syscall)",
	ptrace.StateStuck:                   "stuck",
	ptrace.StateReady:                   "ready",
	ptrace.StateWaitingPreempted:        "preempted",
	ptrace.StateCreated:                 "created",
	ptrace.StateGCMarkAssist:            "GC (mark assist)",
	ptrace.StateGCSweep:                 "GC (sweep assist)",
	ptrace.StateUserRegion:              "user region",
	ptrace.StateTask:                    "task",
	ptrace.StateStack:                   "stack frame",
	ptrace.StateProcRunningNoG:          "proc running without goroutine",
	ptrace.StateProcRunningG:            "proc running",
	ptrace.StateProcRunningBlocked:      "proc waiting for goroutine to unblock",
}

// Mapping from states to their names as used by statistics, filters, etc.
var stateNamesCapitalized = [ptrace.StateLast]string{
	ptrace.StateUndetermined:            "Undetermined",
	ptrace.StateInactive:                "Inactive",
	ptrace.StateActive:                  "Active",
	ptrace.StateGCIdle:                  "GC (idle)",
	ptrace.StateGCDedicated:             "GC (dedicated)",
	ptrace.StateGCFractional:            "GC (fractional)",
	ptrace.StateBlocked:                 "Blocked (other)",
	ptrace.StateBlockedSend:             "Blocked (channel send)",
	ptrace.StateBlockedRecv:             "Blocked (channel receive)",
	ptrace.StateBlockedSelect:           "Blocked (select)",
	ptrace.StateBlockedSync:             "Blocked (sync)",
	ptrace.StateBlockedSyncOnce:         "Blocked (sync.Once)",
	ptrace.StateBlockedSyncTriggeringGC: "Blocked (triggering GC)",
	ptrace.StateBlockedCond:             "Blocked (sync.Cond)",
	ptrace.StateBlockedNet:              "Blocked (pollable I/O)",
	ptrace.StateBlockedGC:               "Blocked (GC)",
	ptrace.StateBlockedSyscall:          "Blocked (syscall)",
	ptrace.StateStuck:                   "Stuck",
	ptrace.StateReady:                   "Ready",
	ptrace.StateWaitingPreempted:        "Preempted",
	ptrace.StateCreated:                 "Created",
	ptrace.StateGCMarkAssist:            "GC (mark assist)",
	ptrace.StateGCSweep:                 "GC (sweep assist)",
	ptrace.StateUserRegion:              "User region",
	ptrace.StateTask:                    "Task",
	ptrace.StateStack:                   "Stack frame",
	ptrace.StateCPUSample:               "Stack frame (sampled)",
	ptrace.StateProcRunningNoG:          "Proc running without goroutine",
	ptrace.StateProcRunningG:            "Proc running",
	ptrace.StateProcRunningBlocked:      "Proc waiting for goroutine to unblock",
}
